using Godot;
using System;
using CurrentGame.Utils.Interpolation;


public partial class PlayerLightLayer : PointLight2D
{
	[Export]
	public bool LightVisible
	{
		get => _lightVisible;
		set
		{
			_lightVisible = value;
			_interpolation.Value = _lightVisible ? 1.0f : 0.0f;
		}
	}
	private bool _lightVisible = true;

	public float Weight
	{
		get => _interpolation.Weight;
		set => _interpolation.Weight = value;
	}

	private LerpInterpolation _interpolation;

	public PlayerLightLayer()
	{
		_interpolation = new LerpInterpolation(0.001f, new Vector3(0.001f, -1, -1));
		_interpolation.Weight = 0.1f;
	}

	public override void _Ready()
	{
		_interpolation.Value = 1.0f;
		_interpolation.Teleport();
	}

	public override void _Process(double delta)
	{
		if (_interpolation.Process(delta))
		{
			var c = Color;
			c.A = _interpolation.Value;
			Color = c;
		}
	}
}
